<?php


abstract class BaseRecord extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $artist_name;


	
	protected $song_name;


	
	protected $album_name;


	
	protected $genre;


	
	protected $nendai;


	
	protected $rebel;


	
	protected $photo;


	
	protected $mp3;


	
	protected $created_at;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getArtistName()
	{

		return $this->artist_name;
	}

	
	public function getSongName()
	{

		return $this->song_name;
	}

	
	public function getAlbumName()
	{

		return $this->album_name;
	}

	
	public function getGenre()
	{

		return $this->genre;
	}

	
	public function getNendai()
	{

		return $this->nendai;
	}

	
	public function getRebel()
	{

		return $this->rebel;
	}

	
	public function getPhoto()
	{

		return $this->photo;
	}

	
	public function getMp3()
	{

		return $this->mp3;
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
						$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = RecordPeer::ID;
		}

	} 
	
	public function setArtistName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->artist_name !== $v) {
			$this->artist_name = $v;
			$this->modifiedColumns[] = RecordPeer::ARTIST_NAME;
		}

	} 
	
	public function setSongName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->song_name !== $v) {
			$this->song_name = $v;
			$this->modifiedColumns[] = RecordPeer::SONG_NAME;
		}

	} 
	
	public function setAlbumName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->album_name !== $v) {
			$this->album_name = $v;
			$this->modifiedColumns[] = RecordPeer::ALBUM_NAME;
		}

	} 
	
	public function setGenre($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->genre !== $v) {
			$this->genre = $v;
			$this->modifiedColumns[] = RecordPeer::GENRE;
		}

	} 
	
	public function setNendai($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nendai !== $v) {
			$this->nendai = $v;
			$this->modifiedColumns[] = RecordPeer::NENDAI;
		}

	} 
	
	public function setRebel($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->rebel !== $v) {
			$this->rebel = $v;
			$this->modifiedColumns[] = RecordPeer::REBEL;
		}

	} 
	
	public function setPhoto($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->photo !== $v) {
			$this->photo = $v;
			$this->modifiedColumns[] = RecordPeer::PHOTO;
		}

	} 
	
	public function setMp3($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->mp3 !== $v) {
			$this->mp3 = $v;
			$this->modifiedColumns[] = RecordPeer::MP3;
		}

	} 
	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = RecordPeer::CREATED_AT;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->artist_name = $rs->getString($startcol + 1);

			$this->song_name = $rs->getString($startcol + 2);

			$this->album_name = $rs->getString($startcol + 3);

			$this->genre = $rs->getString($startcol + 4);

			$this->nendai = $rs->getString($startcol + 5);

			$this->rebel = $rs->getString($startcol + 6);

			$this->photo = $rs->getString($startcol + 7);

			$this->mp3 = $rs->getString($startcol + 8);

			$this->created_at = $rs->getTimestamp($startcol + 9, null);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 10; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Record object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RecordPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			RecordPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isNew() && !$this->isColumnModified(RecordPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RecordPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = RecordPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += RecordPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = RecordPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RecordPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getArtistName();
				break;
			case 2:
				return $this->getSongName();
				break;
			case 3:
				return $this->getAlbumName();
				break;
			case 4:
				return $this->getGenre();
				break;
			case 5:
				return $this->getNendai();
				break;
			case 6:
				return $this->getRebel();
				break;
			case 7:
				return $this->getPhoto();
				break;
			case 8:
				return $this->getMp3();
				break;
			case 9:
				return $this->getCreatedAt();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RecordPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getArtistName(),
			$keys[2] => $this->getSongName(),
			$keys[3] => $this->getAlbumName(),
			$keys[4] => $this->getGenre(),
			$keys[5] => $this->getNendai(),
			$keys[6] => $this->getRebel(),
			$keys[7] => $this->getPhoto(),
			$keys[8] => $this->getMp3(),
			$keys[9] => $this->getCreatedAt(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RecordPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setArtistName($value);
				break;
			case 2:
				$this->setSongName($value);
				break;
			case 3:
				$this->setAlbumName($value);
				break;
			case 4:
				$this->setGenre($value);
				break;
			case 5:
				$this->setNendai($value);
				break;
			case 6:
				$this->setRebel($value);
				break;
			case 7:
				$this->setPhoto($value);
				break;
			case 8:
				$this->setMp3($value);
				break;
			case 9:
				$this->setCreatedAt($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RecordPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setArtistName($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setSongName($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setAlbumName($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setGenre($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setNendai($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setRebel($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setPhoto($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setMp3($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(RecordPeer::DATABASE_NAME);

		if ($this->isColumnModified(RecordPeer::ID)) $criteria->add(RecordPeer::ID, $this->id);
		if ($this->isColumnModified(RecordPeer::ARTIST_NAME)) $criteria->add(RecordPeer::ARTIST_NAME, $this->artist_name);
		if ($this->isColumnModified(RecordPeer::SONG_NAME)) $criteria->add(RecordPeer::SONG_NAME, $this->song_name);
		if ($this->isColumnModified(RecordPeer::ALBUM_NAME)) $criteria->add(RecordPeer::ALBUM_NAME, $this->album_name);
		if ($this->isColumnModified(RecordPeer::GENRE)) $criteria->add(RecordPeer::GENRE, $this->genre);
		if ($this->isColumnModified(RecordPeer::NENDAI)) $criteria->add(RecordPeer::NENDAI, $this->nendai);
		if ($this->isColumnModified(RecordPeer::REBEL)) $criteria->add(RecordPeer::REBEL, $this->rebel);
		if ($this->isColumnModified(RecordPeer::PHOTO)) $criteria->add(RecordPeer::PHOTO, $this->photo);
		if ($this->isColumnModified(RecordPeer::MP3)) $criteria->add(RecordPeer::MP3, $this->mp3);
		if ($this->isColumnModified(RecordPeer::CREATED_AT)) $criteria->add(RecordPeer::CREATED_AT, $this->created_at);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(RecordPeer::DATABASE_NAME);

		$criteria->add(RecordPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setArtistName($this->artist_name);

		$copyObj->setSongName($this->song_name);

		$copyObj->setAlbumName($this->album_name);

		$copyObj->setGenre($this->genre);

		$copyObj->setNendai($this->nendai);

		$copyObj->setRebel($this->rebel);

		$copyObj->setPhoto($this->photo);

		$copyObj->setMp3($this->mp3);

		$copyObj->setCreatedAt($this->created_at);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new RecordPeer();
		}
		return self::$peer;
	}

} 